namespace AutoClub.Core.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class RequiredAttributes : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Races", "State_Id", "dbo.RaceStates");
            DropForeignKey("dbo.Races", "Category_Id", "dbo.CarCategories");
            DropForeignKey("dbo.Users", "Rol_Id", "dbo.UserRols");
            DropForeignKey("dbo.Users", "RaceCategory_Id", "dbo.CarCategories");
            DropForeignKey("dbo.RaceMechanics", "Race_Id", "dbo.Races");
            DropForeignKey("dbo.RaceMechanics", "Mechanic_Id", "dbo.Mechanics");
            DropIndex("dbo.Races", new[] { "State_Id" });
            DropIndex("dbo.Races", new[] { "Category_Id" });
            DropIndex("dbo.Users", new[] { "Rol_Id" });
            DropIndex("dbo.Users", new[] { "RaceCategory_Id" });
            DropIndex("dbo.RaceMechanics", new[] { "Race_Id" });
            DropIndex("dbo.RaceMechanics", new[] { "Mechanic_Id" });
            AlterColumn("dbo.Mechanics", "Name", c => c.String(nullable: false));
            AlterColumn("dbo.Mechanics", "LastName", c => c.String(nullable: false));
            AlterColumn("dbo.Mechanics", "Dni", c => c.String(nullable: false));
            AlterColumn("dbo.Races", "State_Id", c => c.Int(nullable: false));
            AlterColumn("dbo.Races", "Category_Id", c => c.Int(nullable: false));
            AlterColumn("dbo.RaceStates", "Description", c => c.String(nullable: false));
            AlterColumn("dbo.CarCategories", "Description", c => c.String(nullable: false));
            AlterColumn("dbo.Users", "Email", c => c.String(nullable: false));
            AlterColumn("dbo.Users", "Password", c => c.String(nullable: false));
            AlterColumn("dbo.Users", "Rol_Id", c => c.Int(nullable: false));
            AlterColumn("dbo.Users", "RaceCategory_Id", c => c.Int(nullable: false));
            AlterColumn("dbo.UserRols", "Description", c => c.String(nullable: false));
            AlterColumn("dbo.RaceMechanics", "Race_Id", c => c.Guid(nullable: false));
            AlterColumn("dbo.RaceMechanics", "Mechanic_Id", c => c.Guid(nullable: false));
            AddForeignKey("dbo.Races", "State_Id", "dbo.RaceStates", "Id", cascadeDelete: true);
            AddForeignKey("dbo.Races", "Category_Id", "dbo.CarCategories", "Id", cascadeDelete: true);
            AddForeignKey("dbo.Users", "Rol_Id", "dbo.UserRols", "Id", cascadeDelete: true);
            AddForeignKey("dbo.Users", "RaceCategory_Id", "dbo.CarCategories", "Id", cascadeDelete: true);
            AddForeignKey("dbo.RaceMechanics", "Race_Id", "dbo.Races", "Id", cascadeDelete: true);
            AddForeignKey("dbo.RaceMechanics", "Mechanic_Id", "dbo.Mechanics", "Id", cascadeDelete: true);
            CreateIndex("dbo.Races", "State_Id");
            CreateIndex("dbo.Races", "Category_Id");
            CreateIndex("dbo.Users", "Rol_Id");
            CreateIndex("dbo.Users", "RaceCategory_Id");
            CreateIndex("dbo.RaceMechanics", "Race_Id");
            CreateIndex("dbo.RaceMechanics", "Mechanic_Id");
        }
        
        public override void Down()
        {
            DropIndex("dbo.RaceMechanics", new[] { "Mechanic_Id" });
            DropIndex("dbo.RaceMechanics", new[] { "Race_Id" });
            DropIndex("dbo.Users", new[] { "RaceCategory_Id" });
            DropIndex("dbo.Users", new[] { "Rol_Id" });
            DropIndex("dbo.Races", new[] { "Category_Id" });
            DropIndex("dbo.Races", new[] { "State_Id" });
            DropForeignKey("dbo.RaceMechanics", "Mechanic_Id", "dbo.Mechanics");
            DropForeignKey("dbo.RaceMechanics", "Race_Id", "dbo.Races");
            DropForeignKey("dbo.Users", "RaceCategory_Id", "dbo.CarCategories");
            DropForeignKey("dbo.Users", "Rol_Id", "dbo.UserRols");
            DropForeignKey("dbo.Races", "Category_Id", "dbo.CarCategories");
            DropForeignKey("dbo.Races", "State_Id", "dbo.RaceStates");
            AlterColumn("dbo.RaceMechanics", "Mechanic_Id", c => c.Guid());
            AlterColumn("dbo.RaceMechanics", "Race_Id", c => c.Guid());
            AlterColumn("dbo.UserRols", "Description", c => c.String());
            AlterColumn("dbo.Users", "RaceCategory_Id", c => c.Int());
            AlterColumn("dbo.Users", "Rol_Id", c => c.Int());
            AlterColumn("dbo.Users", "Password", c => c.String());
            AlterColumn("dbo.Users", "Email", c => c.String());
            AlterColumn("dbo.CarCategories", "Description", c => c.String());
            AlterColumn("dbo.RaceStates", "Description", c => c.String());
            AlterColumn("dbo.Races", "Category_Id", c => c.Int());
            AlterColumn("dbo.Races", "State_Id", c => c.Int());
            AlterColumn("dbo.Mechanics", "Dni", c => c.String());
            AlterColumn("dbo.Mechanics", "LastName", c => c.String());
            AlterColumn("dbo.Mechanics", "Name", c => c.String());
            CreateIndex("dbo.RaceMechanics", "Mechanic_Id");
            CreateIndex("dbo.RaceMechanics", "Race_Id");
            CreateIndex("dbo.Users", "RaceCategory_Id");
            CreateIndex("dbo.Users", "Rol_Id");
            CreateIndex("dbo.Races", "Category_Id");
            CreateIndex("dbo.Races", "State_Id");
            AddForeignKey("dbo.RaceMechanics", "Mechanic_Id", "dbo.Mechanics", "Id");
            AddForeignKey("dbo.RaceMechanics", "Race_Id", "dbo.Races", "Id");
            AddForeignKey("dbo.Users", "RaceCategory_Id", "dbo.CarCategories", "Id");
            AddForeignKey("dbo.Users", "Rol_Id", "dbo.UserRols", "Id");
            AddForeignKey("dbo.Races", "Category_Id", "dbo.CarCategories", "Id");
            AddForeignKey("dbo.Races", "State_Id", "dbo.RaceStates", "Id");
        }
    }
}
